package tWeight;

import java.util.Stack;

import matrics.SparseVector;
import myLucene.Props;

public class WeightDist {
	public static SparseVector weightDist(SparseVector sp) throws Exception {
		SparseVector wSp = new SparseVector(sp.size());
		int smoothing =Props.smoothingDistWeight;
		for (int i = 0; i < sp.size(); i++) {
			if(sp.isEmpty){
				break;
			}
			double counts = sp.get(i);
			double wCounts = 0.0;
			if(i<sp.size()/2){
			counts = sp.get(i);
			wCounts = Math.pow(Math.E, (-((Math
					.pow(sp.size() / 2-i-1, 2)) / smoothing)))
					* counts;

			if (counts != 0) {
//				System.out.println("Weighted Distance : "
//						+ counts
//						+ " --> "
//						+ wCounts
//						+ "  "
//						+Math.pow(Math.E, (-((Math
//								.pow(sp.size() / 2-i-1, 2)) / smoothing)))
//						+" section: "+(-(sp.size() / 2-i))
//						+" index: "+ i+ " Vec Length "+ wSp.size());
			}
			}
			if(i >= sp.size()/2){
				counts = sp.get(i);
				wCounts = Math.pow(Math.E, (-((Math
						.pow((sp.size() / 2)+i-sp.size()+1-1, 2)) / smoothing)))
						* counts;
				
				
				if (counts != 0) {
//					System.out.println("Weighted Distance : "
//							+ counts
//							+ " --> "
//							+ wCounts
//							+ "  "
//							+Math.pow(Math.E, (-((Math
//									.pow((sp.size() / 2)+i-sp.size()+1-1, 2)) / smoothing)))
//							+" section: "+((sp.size() / 2)+i-sp.size()+1)
//							+" index: "+ i);
				}
			}
			wSp.put(i, wCounts);

		}
		return wSp;
	}

}
